#include<iostream>
#include<algorithm>
using namespace std;
int n;
int main()
{
	int t;
	cin >> t;
	while (t--) {
		cin >> n;
		int mi = n;
		for (int i = 0; i <= n / 150; i++) {
			for (int j = 0; j <= n / 200; j++) {
				for (int k = 0; k <= n / 350; k++) {
					int m = 150 * i + 200 * j + 350 * k;
					//cout << m << " ";
					if (n >= m) {
						mi = min(mi, n - m);
					}
				}
			}
		}
		cout << mi << endl;
	}
	return 0;
}